import {title, version, hmt} from '/src/config/env';
import website from './config/website';
import {createApp} from 'vue';
import App from './App.vue';
import router from './router/router';
import store from './store/store';
import './scrollBar.css';
import './grid.css';
import './index.css';

let app = createApp(App);

// Antd
import Antd from 'ant-design-vue';
import 'ant-design-vue/dist/antd.css';
app.use(Antd);

// IconPark
// import {install} from '@icon-park/vue-next/es/all';
// import '@icon-park/vue-next/styles/index.css';
// install(app); // use default prefix 'icon', eg: icon is People, name is icon-people.

// 设置标题
router.beforeEach((to, from, next) => {
    if (to.meta.content) {
        document.querySelector('meta[name="keywords"]').setAttribute('content', to.meta.content.keywords);
        document.querySelector('meta[name="description"]').setAttribute('content', to.meta.content.description);
    }
    if (to.meta.title) {
        document.title = website.title + ' - ' + to.meta.title;
    }
    if (hmt) {
        setTimeout(() => {
            window._hmt = window._hmt || [];
            (function () {
                let hm = document.createElement("script");
                hm.src = "https://hm.baidu.com/hm.js?" + hmt;
                let s = document.getElementsByTagName("script")[0];
                s.parentNode.insertBefore(hm, s);
            })();
        }, 0);
    }
    next();
});

// 标记
console.log(
    `%c ${title} %c Version:${version} %c`,
    'background:#35495e; padding: 2px; border-radius: 3px 0 0 3px;  color: #fff',
    'background:#41b883; padding: 2px; border-radius: 0 3px 3px 0;  color: #fff',
    'background:transparent;'
);

// app
app.use(router).use(store).mount('#app');
